package com.zbf.api;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @author: LCG
 * 作者: LCG
 * 日期: 2021/6/18  17:26
 * 描述: Fegin接口的降级类
 */
@Component
public class TestFeginApiImpl implements TestFeginApi {

    private Throwable throwable;

    public TestFeginApiImpl(Throwable throwable) {
        this.throwable = throwable;
    }

    public TestFeginApiImpl() {
    }

    public Object getuserList(Map<String, Object> map) {

       if(throwable!=null){
           String message = throwable.getMessage();
           String content = message.split("content")[1].substring(1);
           JSONObject jsonObject = JSON.parseObject(content);

           System.out.println(jsonObject.get("message"));
       }

        return "调用出错了----》"+map;
    }
}
